package com.southern.gateway.base;/*
 *
 *@Author:tangchao
 *@Description:
 *@Date:2022/1/7
 * */

public class ResultModel {
    public static final String SUCESS_CODE = "0";
    public static final String ERROR_CODE = "1";
    private String code = "0";
    private String msg;
    private Object data;

    public ResultModel() {
    }

    public ResultModel(String msg) {
        this.msg = msg;
    }

    public ResultModel(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResultModel(Object data) {
        this.code = "0";
        this.data = data;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return this.msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return this.data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    /** @deprecated */
    @Deprecated
    public static ResultModel getSuccessModel() {
        return new ResultModel("0");
    }

    /** @deprecated */
    @Deprecated
    public static ResultModel getSuccessModel(Object date) {
        return new ResultModel(date);
    }

    /** @deprecated */
    @Deprecated
    public static ResultModel getErrorModel(String message) {
        return new ResultModel("1", message);
    }

    /** @deprecated */
    @Deprecated
    public static ResultModel getErrorModel(String code, String errorMsg) {
        return new ResultModel(code, errorMsg);
    }

    public static ResultModel success() {
        return new ResultModel("0");
    }

    public static ResultModel success(Object data) {
        return new ResultModel(data);
    }

    public static ResultModel error(String code, String errorMsg) {
        return new ResultModel(code, errorMsg);
    }

    public static ResultModel errorMessage(String message) {
        return new ResultModel("1", message);
    }

    public static ResultModel errorCode(String code) {
        return new ResultModel(code, ErrorMessage.getMessage(code));
    }
}
